#include <iostream>
#include <string>

int main() {
    std::string a;
    std::cout << "Введите скобочную последовательность:";
    std::cin >> a;
    for (size_t i = 0; i < a.length(); ++i) {
        if (a[i] == '(') {
            if (i + 1 < a.length() && (a[i + 1] == ')' || (i + 2 < a.length() && a[i + 2] == ')'))) {
                std::cout << "True" << std::endl;
                break;
            } else {
                std::cout << "False" << std::endl;
                break;
            }
        }
        if (a[i] == '[') {
            if (i + 1 < a.length() && (a[i + 1] == ']' || (i + 2 < a.length() && a[i + 2] == ']'))) {
                std::cout << "True" << std::endl;
                break;
            } else {
                std::cout << "False" << std::endl;
                break;
            }
        }
        if (a[i] == '{') {
            if (i + 1 < a.length() && (a[i + 1] == '}' || (i + 2 < a.length() && a[i + 2] == '}'))) {
                std::cout << "True" << std::endl;
                break;
            } else {
                std::cout << "False" << std::endl;
                break;
            }
        }
        if (a[i] == '<') {
            if (i + 1 < a.length() && (a[i + 1] == '>' || (i + 2 < a.length() && a[i + 2] == '>'))) {
                std::cout << "True" << std::endl;
                break;
            } else {
                std::cout << "False" << std::endl;
                break;
            }
        }
        if (a[i] == ' ') {
            if (i + 1 < a.length() && (a[i + 1] == ' ' || (i + 2 < a.length() && a[i + 2] == ' '))) {
                std::cout << "True" << std::endl;
                break;
            } else {
                std::cout << "False" << std::endl;
                break;
            }
        } else {
            std::cout << "False" << std::endl;
            break;
        }
    }
    return 0;
}